package javatest;
import java.util.Scanner;

public class test2 {
    public static void main(String[] args) {
        int sum = 20;
        int book = 12;
        int pencile = 1;
        int rubber = 2;
        int cola = 3;
        int food = 5;
        int money = sum - book;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要购买的商品：");
        String a = scanner.next();
        switch (a) {
            case "书本":
                System.out.println("购买一本书后，还可以购买" + money / book + "本书本，还剩" + money % book + "元");
                break;

            case "铅笔":
                System.out.println("购买一本书后，还可以购买" + money / pencile + "支铅笔，还剩" + money % pencile + "元");
                break;

            case "橡皮":
                System.out.println("购买一本书后，还可以购买" + money / rubber + "个橡皮，还剩" + money % rubber + "元");
                break;

            case "可乐":
                System.out.println("购买一本书后，还可以购买" + money / cola + "瓶可乐，还剩" + money % cola + "元");
                break;

            case "零食":
                System.out.println("购买一本书后，还可以购买" + money / food + "个零食，还剩" + money % food + "元");
                break;

            default: {
                System.out.println("输入错误，没有该商品");
                break;
            }


        }
    }
}
